<template>
  <div class="tabbar-item" @click="itemClick">
        <slot name="slot-tab-icon" v-if="!isActive"></slot>
        <slot name="slot-tab-icon-active" v-else></slot>
    <div :class="isActive?'active':''">
        <slot name="slot-tab-text"></slot>
    </div>
  </div>
</template>

<script>
export default {
  components:{},
  props:{
    path:String
  },
  data(){
    return {
    }
  },
  computed:{
    isActive(){
	  //查看是否是当前路由路径
      return this.$route.path.indexOf(this.path)!=-1
    },
  },
  methods:{
    itemClick(){
		//切换路由路径
      this.$router.replace(this.path)
    }
  }
}
</script>
<style scoped>
  .tabbar-item{
      flex: 1;
      text-align: center;
      font-size: 14px;
  }
  .tabbar-item>>>img{
      width: 24px;
      height: 24px;
      margin-top: 3px;
      vertical-align: middle;
      margin-bottom: 2px;
  }
  .active{
    color: red;
  }
</style>